package cn.liulingfengyu.behavioralpatterns.strategypattern;

/**
 * 策略模式示例
 */
public class StrategyPatternDemo {
    public static void main(String[] args) {
        // 创建上下文对象并设置策略A
        Context context = new Context(new ConcreteStrategyA());
        System.out.println("使用策略A：");
        context.executeStrategy();

        // 更改策略为策略B
        context.setStrategy(new ConcreteStrategyB());
        System.out.println("使用策略B：");
        context.executeStrategy();
    }
}